package com.youxin.dataStream.custormSource;

import org.apache.flink.streaming.api.datastream.DataStreamSink;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.windowing.time.Time;

/**
 * 并行度为1的source
 * 疑问：下面这个任务要怎么划分
 */
public class StreamWithSimgleParalleSource {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        DataStreamSource<Long> text = env.addSource(new SimgleParalleSource()).setParallelism(1);//并行度只能为1   Source: 1 is not a parallel source
        text.print();
        SingleOutputStreamOperator<Long> sum = text.timeWindowAll(Time.seconds(2)).sum(0);
        sum.print().setParallelism(1);
        env.execute("simgleParalle");
    }
}
